package sy6_Behavioral_Pattern.strategy.ex1;

interface TravelStrategy{
	public void way();
}
class ConcreteWay1 implements TravelStrategy{

	@Override
	public void way() {
		System.err.println("乘坐高铁出行！");
	}
}
class ConcreteWay2 implements TravelStrategy{

	@Override
	public void way() {
		System.err.println("乘坐大巴出行！");
	}
}
class ConcreteWay3 implements TravelStrategy{

	@Override
	public void way() {
		System.err.println("乘坐飞机出行！");
	}
}

class Context{
	private TravelStrategy travelStrategy;

	public void setTravelStrategy(TravelStrategy travelStrategy) {
		this.travelStrategy = travelStrategy;
	}
	public void contextInterface() {
		travelStrategy.way();
	}
}

public class Travel {
	public static void main(String[] args) {
		TravelStrategy travelStrategy=new ConcreteWay2();
		Context context=new Context();
		context.setTravelStrategy(travelStrategy);
		context.contextInterface();
	}

}
